package com.pinghua.mocha.basics.enumerate.fwct;

import com.coffee.core.CoffeeEnum;
import com.fasterxml.jackson.annotation.JsonValue;

import java.util.ArrayList;
import java.util.List;

public enum WarningTypeDetailEnum implements CoffeeEnum<Integer> {

    Investment(5,"垃圾混投", WarningTypeEnum.Merchants),
    Refused(6,"拒签合同", WarningTypeEnum.Merchants),
    Filter(7,"滤油滤水", WarningTypeEnum.Merchants),
    Waste(8,"餐饮浪费", WarningTypeEnum.Merchants),
    Misplacing(9,"桶脏/乱放", WarningTypeEnum.Merchants),
    Reselling(10,"废油倒卖", WarningTypeEnum.Merchants),
    SWILL(11,"乱排泔水", WarningTypeEnum.Merchants),
    STANDING(12,"台账作假", WarningTypeEnum.Merchants),
    Missing(13,"台账缺失", WarningTypeEnum.Merchants),
    BARREL(14,"桶破", WarningTypeEnum.Merchants),

    Receivable(15,"应收未收", WarningTypeEnum.Recycle),
    Speeding(16,"超速超载", WarningTypeEnum.Recycle),
    Reviews(17,"服务差评", WarningTypeEnum.Recycle),
    Fault(18,"设备故障", WarningTypeEnum.Recycle),
    RUNNING(19,"跑冒滴漏", WarningTypeEnum.Recycle),

    WEIGHBRIDGE(20,"地磅故障", WarningTypeEnum.Disposal),
    EXCEEDS(21,"废水超标", WarningTypeEnum.Disposal),
    EXHAUST(22,"废气超标", WarningTypeEnum.Disposal),

    Illegal(23,"违法收运", WarningTypeEnum.Illegal),
    Disposal(24,"违法处置", WarningTypeEnum.Illegal);

    @JsonValue
    private final Integer code;
    private final String label;
    private final WarningTypeEnum type;
    WarningTypeDetailEnum(Integer code, String label, WarningTypeEnum type) {
        this.code = code;
        this.label = label;
        this.type = type;
    }

    @Override
    public Integer code() {
        return this.code;
    }

    @Override
    public String label() {
        return this.label;
    }

    public static List<WarningTypeDetailEnum> ofEnum(WarningTypeEnum type) {
        ArrayList<WarningTypeDetailEnum> list = new ArrayList<>();
        for (WarningTypeDetailEnum typeDetail : values()) {
            if (typeDetail.type.equals(type)) {
                list.add(typeDetail);
            }
        }
        return list;
    }

    public static WarningTypeDetailEnum ofCode(Integer code) {
        for (WarningTypeDetailEnum type : values()) {
            if (type.code.equals(code)) {
                return type;
            }
        }
        return null;
    }

    public static List<WarningTypeDetailEnum> list() {
        ArrayList<WarningTypeDetailEnum> list = new ArrayList<>();
        for (WarningTypeDetailEnum type : values()) {
            list.add(type);
        }
        return list;
    }

    public static List<WarningTypeDetailEnum> listByType(WarningTypeEnum type) {
        ArrayList<WarningTypeDetailEnum> list = new ArrayList<>();
        for (WarningTypeDetailEnum detailType : values()) {
            if (detailType.type == WarningTypeEnum.Merchants) list.add(detailType);
        }
        return list;
    }

    public Integer type() {
        return this.type.code();
    }
}
